<?php
namespace App\Providers\VersionTraits;

use App\Wen\Utils\Settings;
use Dcat\Admin\Models\AdminSubMenu;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

trait _1_2_10_3_trait{

    function _v1_2_2_21(){
        if(!AdminSubMenu::where('uri', '/settings/pagenotice')->exists()){
            $admin_menu = new AdminSubMenu();
            $admin_menu->parent_id =Settings::get('sub_menu_page_config_parent_id', 0);
            $admin_menu->order = 1020;
            $admin_menu->icon = 'fa-comments-o';
            $admin_menu->title = '消息页';
            $admin_menu->uri = '/settings/pagenotice';
            $admin_menu->extension = '';
            $admin_menu->show = 1;
            $admin_menu->save();
        }
        if(!AdminSubMenu::where('uri', '/settings/subpagemine')->exists()){
            $admin_menu = new AdminSubMenu();
            $admin_menu->parent_id =Settings::get('sub_menu_page_config_parent_id', 0);
            $admin_menu->order = 1021;
            $admin_menu->icon = 'fa-street-view';
            $admin_menu->title = '用户页';
            $admin_menu->uri = '/settings/subpagemine';
            $admin_menu->extension = '';
            $admin_menu->show = 1;
            $admin_menu->save();
        }
    }

    function _v1_2_2_24(){

        if(!Schema::hasColumn('wx_shop_goods', 'collect_from_url')){
            Schema::table('wx_shop_goods', function (Blueprint $table) {
                $table->string('collect_from_url', 500)->after('state')->nullable()->comment('采集链接');
            });
        }

        if(!Schema::hasColumn('wx_user_setting', 'diy_short_vibrate_feedback')){
            Schema::table('wx_user_setting', function (Blueprint $table) {
                $table->unsignedTinyInteger('diy_short_vibrate_feedback')->default(1)->after('diy_scene_8_post_list_style')->comment('短震动触感');
            });
        }

        if(!Schema::hasColumn('wx_user_setting', 'social_sph_id')){
            Schema::table('wx_user_setting', function (Blueprint $table) {
                $table->string('social_sph_id', 15)->default('')->after('diy_short_vibrate_feedback')->comment('视频号id');
            });
        }

    }

    function _v1_2_2_25(){

        if(!Schema::hasColumn('wx_university', 'sem_start_date_1')){
            Schema::table('wx_university', function (Blueprint $table) {
                $table->date('sem_end_date_2')->nullable()->after('email_suffix')->comment('最后一周最后一天(二)');
                $table->date('sem_start_date_2')->nullable()->after('email_suffix')->comment('第一周第一天(二)');
                $table->date('sem_end_date_1')->nullable()->after('email_suffix')->comment('最后一周最后一天(一)');
                $table->date('sem_start_date_1')->nullable()->after('email_suffix')->comment('第一周第一天(一)');
            });
        }

    }


}
